<template>
	<view>
		<template v-if="newsList && newsList.length">
			<view class="flex u-m-b-20 newsItem" v-for="(news,newsI) in newsList" :key="news.id"
				@click="openNews(news,newsI)">
				<view class="tags shrink-0">
				</view>
				<view class="u-flex-1">
					<view class="u-font-28 color333 u-m-b-24 word-break-all">{{news.title}}</view>
					<view class="flex align-center u-font-24 color999">
						<view>{{news.createTime}}</view>
						<view class="line">|</view>
						<view>赞{{news.giveUpCount || 0}}</view>
						<view class="line">|</view>
						<view>浏览{{news.browseCount || 0}}</view>
					</view>
				</view>
			</view>
			<view class="u-m-t-40">
				<u-loadmore :status="status" />
			</view>
		</template>
		<view v-else>
			<uni-nodata noText="还没有最新调剂信息"></uni-nodata>
		</view>
	</view>
</template>

<script>
	import {
		newarticleDetails

	} from '@/api/toolbox.js';
	export default {
		props: ['schoolCode'],
		data() {
			return {
				status: "loadmore",
				newsList: [],
				page: {
					page: 1,
					pageSize: 10,
					type: 2
				}
			}
		},
		methods: {
			reachBottom() {
				if (this.status == 'nomore') return;
				this.status = 'loading';
				this.page.page++;
				this.getNews();
			},
			openNews(row, index) {
				uni.setStorageSync('article', JSON.stringify(row));
				uni.navigateTo({
					url: `/pages/school/isomorphism/dynamicDetails/dynamicDetails?state=${index}`
				})
			},
			getNews() {
				newarticleDetails({
					page: this.page.page,
					pageSize: this.page.pageSize,
					code: this.schoolCode,
					type: this.page.type
				}).then(res => {
					if (res.data && res.data.list.length) {
						if (this.page.page == 1) {
							this.newsList = res.data.list;
						} else {
							this.newsList.push(...res.data.list);
						}
					}
					if (!res.data || !res.data.list || res.data.list.length < this.page.pageSize) {
						this.status = 'nomore';
					} else {
						this.status = 'loading';
					}
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.empty {
		margin: 0 auto;
		display: flex;
		align-items: center;
		justify-content: center;
		width: 600rpx;
		height: 600rpx;
	}
</style>